package softtech.apps.utilities;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public final class Utilities {
	public static final String SENDER_ID = "651790727073";
	public static final String APP_SERVER_ROOT = "http://208.67.16.55/~softtech/loicuoi/gcmserver/";
	public static final String APP_SERVER_URL = "http://208.67.16.55/~softtech/loicuoi/gcmserver/register.php";
	public static final String APP_SERVER_URL_SEND_MESSAGE = "http://208.67.16.55/~softtech/loicuoi/gcmserver/send_message.php";
	public static final String APP_SERVER_URL_GET_USER = "http://208.67.16.55/~softtech/loicuoi/gcmserver/SyncUserList.php";
	public static final String APP_SERVER_URL_GET_REG = "http://208.67.16.55/~softtech/loicuoi/gcmserver/getRegIds.php";
	public static final String APP_SERVER_URL_UPLOAD = "http://208.67.16.55/~softtech/loicuoi/gcmserver/savetofile.php";
	public static final String APP_SERVER_URL_INSERT_PRODUCT = "http://208.67.16.55/~softtech/loicuoi/gcmserver/insertProduct.php";
	public static final String APP_SERVER_URL_GET_ALL_PRODUCT = "http://208.67.16.55/~softtech/loicuoi/gcmserver/getAllProducts.php";
	public static final String APP_SERVER_URL_GET_PRODUCT_DETAILS = "http://208.67.16.55/~softtech/loicuoi/gcmserver/GetProductDetails.php";
	
	public static final String REG_ID = "regId";
	public static final String APP_VERSION = "appVersion";
	public static final String MESSAGE_BROADCAST = "softtech.apps.dangtinraovat.intent.action.TEST";
	/**
	 * function md5 encryption for passwords
	 * 
	 * @param password
	 * @return passwordEncrypted
	 */
	public static final String md5(final String password) {
	    try {
	 
	        MessageDigest digest = java.security.MessageDigest
	                .getInstance("MD5");
	        digest.update(password.getBytes());
	        byte messageDigest[] = digest.digest();
	 
	        StringBuffer hexString = new StringBuffer();
	        for (int i = 0; i < messageDigest.length; i++) {
	            String h = Integer.toHexString(0xFF & messageDigest[i]);
	            while (h.length() < 2)
	                h = "0" + h;
	            hexString.append(h);
	        }
	        return hexString.toString();
	 
	    } catch (NoSuchAlgorithmException e) {
	        e.printStackTrace();
	    }
	    return "";
	}
}
